var ns;
var app = new Vue({
    el: '#app',
    data: {
      IsShow:false,
      keyword:'',
      NewsType:0,
      messageList:[],
      startRowIndex:0,
      pageSize:10,
      LiveChatList:[],//聊天list

    },
methods:{
  // do_search: function() {
  //     var that = this;
  //       if(that.keySearch!=''){
  //         that.get_data();
  //     }
  // },
  get_data:function(){
      var that = this;
      var opt = {
          action: 'getusermessagelist',
          startRowIndex: that.startRowIndex,
          pageSize: that.pageSize,
      };
      console.log(JSON.stringify(opt));
      ns.post(opt, function(succeed, data, err) {
        console.log(JSON.stringify(succeed));
        console.log(JSON.stringify(data));
        console.log(JSON.stringify(err));
          if (succeed) {
            // if(data!=null)  {
            //     that.IsShow=true;
            // }
            that.messageList = data.messageList.rows;
            that.LiveChatList=data.LiveChatList;
            if(that.messageList.length>0){
              for (let i = 0; i < that.messageList.length; i++) {
                that.messageList[i].CreateTime=ns.SetTime_style(that.messageList[i].CreateTime)
              }

            }
           
          } else if (err) {
              api.toast({
                  msg: err,
                  duration: 2000,
                  location: 'bottom'
              });
          }
      })
  },
  open_message_chatdetail:function(item,type){
    var that=this;
    if(type==201){
      ns.openWin('dl_message_chatdetail_frm', '聊天',{
        id:item.GroupID,
        openid:item.OpenID,
        BusinessID:item.BusinessID
      });
    }
    if(type==1){
      ns.openWin('dl_order_detail', '订单详情',{
        id:item.ID
      });
    }
    if(type==2||type==3||type==4){
      ns.openWin('messageDetail', '退款进度',{
        id:item.ID,
        headerbg:2,
    });
    }
    if(type==5||type==6){
      ns.openWin('xiaoxi_shopshenhe', '审核信息',{
        id:item.ID
      });
    }
    if(type==7||type==8){
      ns.openWin('xiaoxi_productshenhe', '审核信息',{
        id:item.ID
      });
    }
    
    


  },
  // do_openproup:function(type){
  //   var that=this;
  //   if(type==1){
  //     ns.openWin('xiaoxi_shopshenhe', '商家审核信息');
  //   }
  //   else if(type==2){
  //     ns.openWin('xiaoxi_productshenhe', '商品审核信息');
  //   }
   
   
  // },

  }
});
apiready = function() {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.get_data();
    api.addEventListener({
        name: 'onlogin'
    }, function(ret, err) {
        app.get_data();
    });
    api.addEventListener({
        name: 'shopmsgevent'
    }, function(ret, err){
          app.get_data();
    });
};
//时间戳转换方法    date:时间戳数字
function formatDate(date) {
  var date = new Date(date);
  var YY = date.getFullYear() + '-';
  var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
  var DD = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate());
  var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
  var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
  var ss = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
  return YY + MM + DD +" "+hh + mm + ss;
}
